(function(){
	angular.module('app').factory('industrySelectComponentService',industrySelectComponentService);

	industrySelectComponentService.$inject = ['util','$q'];

	function industrySelectComponentService(util,$q){

		return {

			getIndustry:_getIndustry,
			getSub:_getSub,
			submit:_submit
		}

		function _getIndustry(){

			var defer = $q.defer();

			util.$get({
				url:'/marketconditions/index/getCategory.htm'
			}).then(function(resp){

				defer.resolve(resp.value);

			},function(err){

				defer.reject(err);
			});

			return defer.promise;
		}

		function _getSub(_catValue){

			var defer = $q.defer();

			util.$get({
				url:'/marketconditions/category/getTopCategory.htm',
				data:{
					catValue:_catValue
				}
			}).then(function(resp){

				defer.resolve(resp.value);

			},function(err){

				defer.reject(err);
			});

			return defer.promise;
		}

		function _submit(_topCat){

			var defer = $q.defer();

			util.$get({
				url:'/marketconditions/index/updateTopCat.htm',
				data:{
					topCat:_topCat
				}
			}).then(function(resp){

				defer.resolve(resp.value);

			},function(err){

				defer.reject(err);
			});

			return defer.promise;

		}

	}
})();